How To: Use Value Tables in Python as Part of a Geoprocessing Script 您所在的位置:网站首页 python procedure How To: Use Value Tables in Python as Part of a Geoprocessing Script

How To: Use Value Tables in Python as Part of a Geoprocessing Script

#How To: Use Value Tables in Python as Part of a Geoprocessing Script| 来源: 网络整理| 查看: 265

Below is an example of the Merge command NOT using a Value Table:

Code:# Import system modulesimport sys, string, os, win32com.client

# Create the Geoprocessor objectgp = win32com.client.Dispatch("esriGeoprocessing.GpDispatch.1")

# Load required toolboxes...gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Data Management Tools.tbx")

# Process: Merge...gp.Merge_management("C:\\ESRI\\ESRIDATA\\MEX_STATES.shp;C:\\ESRI\\ESRIDATA\\USA_STATES.shp", "C:\\ESRI\\ESRIDATA\\STATES_Merge.shp")

print "done"

This example uses the text value of the multivalue parameter, which can become difficult to use when there are numerous values with complex paths. The Value Table is used to organize the values into a table, so values can be easily added or removed, eliminating the complexity of parsing a multivalue text string. Below is an example using Merge with a Value Table:

Code:# Import system modulesimport sys, string, os, win32com.client

# Create the Geoprocessor objectgp = win32com.client.Dispatch("esriGeoprocessing.GpDispatch.1")

# Set the workspace. gp.Workspace = "C:\\ESRI\\ESRIDATA\\"

# Merge shape type, input Polyline or PolygonshapeType = "Polygon"

gp.OverwriteOutput = 1

# Create the value tablevtab = gp.CreateObject("ValueTable")

# List all of the feature classes in the datasetfcs = gp.ListFeatureClasses()fcs.reset()fc = fcs.next()

# Store all the feature classes in a value tablewhile fc: # Describe the feature class dsc = gp.Describe(fc) if dsc.Shapetype == shapeType: vtab.AddRow(fc) fc = fcs.next()

# Process: Merge...gp.Merge_management(vtab, "C:\\ESRI\\ESRIDATA\\STATES_Merge.shp")

print "done"



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有